<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<div class="container-fluid" id="deployHistoryList" role="main">
    <div class="modal-body">
        <div class="row">
            <form class="form-inline pull-left col-sm-12">
            	<div class="form-group form-group-sm">
                    <label>域名:</label>
                    <input type="text" class="form-control" ng-model="filterVersion">
                </div>
                <div class="form-group form-group-sm">
                    <label>环境:</label>
                    <input type="text" class="form-control" ng-model="filterStr">
                </div>
                
                <button class="btn btn-raised btn-sm btn-primary" type="button" ng-click="openAddEnvDialog()" ng-show="{{isShowEdit}}">{{'ADD' |
                    translate}}
                </button>
 				<button class="btn btn-raised btn-sm btn-primary" type="button" ng-click="openModifyDeptDialog()" ng-show="{{isShowEdit}}">{{'ADDSYS' |
                    translate}}
                </button>
                <button class="btn btn-raised btn-sm btn-primary" type="button" ng-click="openModifyPermissionDialog()" ng-show="{{adminShowEdit}}">{{'ADDPERMISSION' |
                    translate}}
                </button>
            </form>
        </div>
        <br>
        <div>
            <div class="row">
                <table class="table table-bordered text-middle">
                    <tr>
                        <th class="text-center">域名</th>
                        <th class="text-center">环境</th>
                        <th class="text-center">nameServer</th>
                        <th class="text-center">集群名称</th>
                        <th class="text-center">控制台地址</th>
                        <th class="text-center">{{ 'OPERATION' | translate}}</th>
                    </tr>
                    <tr ng-repeat="envInfo in envShowList">
                        <td class="text-center">{{envInfo.regionName}}</td>
                        <td class="text-center">{{envInfo.enviroName}}</td>
                        <td class="text-center" style="word-wrap:break-word;word-break:break-all;">{{envInfo.nameserver}}</td>
                        <td class="text-center">{{handleArrays(envInfo.rmqcluster)}}</td>
                        <td class="text-center">{{envInfo.consoleIp}}</td>
                         <td class="text-center">
                            <button class="btn btn-raised btn-sm btn-danger" type="button"
                                    ng-click="openModifyEnvDialog(envInfo.id)" ng-show="{{isShowEdit}}">修改
                            </button>
                        </td>
                    </tr>
                </table>
            </div>
            <tm-pagination conf="paginationConf"></tm-pagination>
        </div>


    </div>
</div>


<script type="text/ng-template" id="envCreateDialog">
    <div class="modal-header">
        <h4 class="modal-title">新增环境</h4>
    </div>
    <div class="modal-body " ng-repeat="item in ngDialogData.envRequestList">
        <form id="addAppForm" name="addAppForm" class="form-horizontal" novalidate>
			<div class="form-group" ng-hide="ngDialogData.bIsUpdate">
                <label class="control-label col-sm-2">域名:</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectRegionNameList"
                            ng-model="item.regionName"
                            ng-options="(region.regionCode+'-'+region.regionName) for region in ngDialogData.allRegionNameList"
							"
                    >
                        <option value="">-- 请选择 --</option>
                    </select>
                </div>
            </div>
			<div class="form-group" ng-hide="ngDialogData.bIsUpdate">
                <label class="control-label col-sm-2">环境:</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectEnvNameList" 
                            ng-model="item.enviroCode"
                            ng-options="env.enviroName for env in ngDialogData.allEnvNameList"
							"
                    >
                        <option value="">-- 请选择 --</option>
                    </select>
                </div>
            </div>
			<div class="form-group">
                <label class="control-label col-sm-2">nameServerAddr:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.nameserver" type="text"
                           required/>
                    <span class="text-danger" ng-show="addAppForm.name.$error.required">nameserver不能为空.</span>
                </div>
            </div>
			<div class="form-group">
                <label class="control-label col-sm-2">rmq集群名称:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.cluster" type="text"
                           required/>
                    <span class="text-danger" ng-show="addAppForm.name.$error.required">rmq集群名称不能为空.</span>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">新增部门简码</label>
               <div class="col-sm-10">
                    <input class="form-control" ng-model="item.deptCodes" type="text"
                           />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">控制台ip:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.consoleIp" type="text"
                           ng-disabled="ngDialogData.bIsUpdate" required/>
                    <span class="text-danger" ng-show="addAppForm.name.$error.required">控制台ip不能为空.</span>
                </div>
            </div>
        </form>
        <div class="modal-footer">
            <div class="ngdialog-buttons">
                <button type="button" class="ngdialog-button ngdialog-button-primary"
                        ng-click="postenvRequest(item)">{{ 'COMMIT' | translate }}
                </button>
                <button type="button" class="ngdialog-button ngdialog-button-secondary"
                        ng-click="closeThisDialog('Cancel')">{{ 'CLOSE' | translate }}
                </button>
            </div>
        </div>
    </div>

</script>

<script type="text/ng-template" id="envModifyDialog">
    <div class="modal-header">
        <h4 class="modal-title">修改域基本环境信息</h4>
    </div>
    <div class="modal-body " ng-repeat="item in ngDialogData.item">
        <form id="addAppForm" name="addAppForm" class="form-horizontal" novalidate>
			<div class="form-group" ng-hide="ngDialogData.bIsUpdate">
                <label class="control-label col-sm-2">域名:</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectRegionNameList"
                            ng-model="item.regionCode" type="text" required
                            ng-options="region.regionCode as (region.regionCode+'-'+region.regionName) for region in ngDialogData.allRegionNameList"
							"
                    >
					
                    </select>
                </div>
            </div>
			<div class="form-group" ng-hide="ngDialogData.bIsUpdate">
                <label class="control-label col-sm-2">环境:</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectEnvNameList" 
                            ng-model="item.enviroCode"
                            ng-options="env.enviroCode as (env.enviroCode+'-'+env.enviroName) for env in ngDialogData.allEnvNameList"
							"
                    >
                    </select>
                </div>
            </div>
			<div class="form-group">
                <label class="control-label col-sm-2">集群名称:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.rmqcluster" type="text"
                           required/>
                </div>
            </div>
            <div class="form-group" ng-hide="ngDialogData.bIsUpdate">
                <label class="control-label col-sm-2">nameServer:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.nameserver" type="text"
                           required/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">原有部门简码:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.exitDeptCodes" type="text"
                           />
                </div>
            </div>
			<div class="form-group">
                <label class="control-label col-sm-2">新增部门简码</label>
               <div class="col-sm-10">
                    <input class="form-control" ng-model="item.deptCodes" type="text"
                           />
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">控制台ip:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.consoleIp" type="text"
                           ng-disabled="ngDialogData.bIsUpdate" required/>
                    <span class="text-danger" ng-show="addAppForm.name.$error.required">控制台ip不能为空.</span>
                </div>
            </div>
        </form>
        <div class="modal-footer">
            <div class="ngdialog-buttons">
                <button type="button" class="ngdialog-button ngdialog-button-primary"
                        ng-click="postUpdateenvRequest(item)">{{ 'COMMIT' | translate }}
                </button>
                <button type="button" class="ngdialog-button ngdialog-button-secondary"
                        ng-click="closeThisDialog('Cancel')">{{ 'CLOSE' | translate }}
                </button>
            </div>
        </div>
    </div>

</script>

<script type="text/ng-template" id="deptModifyDialog">
    <div class="modal-header">
        <h4 class="modal-title">修改部门</h4>
    </div>
    <div class="modal-body ">
        <form id="addAppForm" name="addAppForm" class="form-horizontal" novalidate>
			<div class="form-group" ng-hide="ngDialogData.bIsUpdate">
                <label class="control-label col-sm-2">部门:</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectDeptList" chosen
                            ng-model="item.code"
                            ng-options="(dept.deptName+'-'+dept.deptCode) for dept in ngDialogData.allDeptList"
							ng-change="changeDept(item.code.deptCode)"
                    >
                        <option value="">-- 请选择 --</option>
                    </select>
                </div>
            </div>
			<div class="form-group">
                <label class="control-label col-sm-2">原有的部门系统:</label>
                <div class="col-sm-10">
                    <input class="form-control" ng-model="item.sysCodes" type="text"
                           />
                </div>
            </div>
			<div class="form-group">
                <label class="control-label col-sm-2">新增部门系统</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectSysNameList" multiple chosen
                            ng-model="item.newSysCodes"
                            ng-options="(sys.sysCode+'-'+sys.sysName) for sys in ngDialogData.allSysNameList"
                    >
                        <option value="">-- 请选择 --</option>
                    </select>
                </div>
            </div>
            
        </form>
        <div class="modal-footer">
            <div class="ngdialog-buttons">
                <button type="button" class="ngdialog-button ngdialog-button-primary"
                        ng-click="postDeptRequest(item)">{{ 'COMMIT' | translate }}
                </button>
                <button type="button" class="ngdialog-button ngdialog-button-secondary"
                        ng-click="closeThisDialog('Cancel')">{{ 'CLOSE' | translate }}
                </button>
            </div>
        </div>
    </div>

</script>
<script type="text/ng-template" id="userPermissionModifyDialog">
    <div class="modal-header">
        <h4 class="modal-title">修改权限</h4>
    </div>
    <div class="modal-body ">
        <form id="addAppForm" name="addAppForm" class="form-horizontal" novalidate>
			<div class="form-group" ng-hide="ngDialogData.bIsUpdate">
                <label class="control-label col-sm-2">人员:</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectUserInfoList" chosen
                            ng-model="item.name"
                            ng-options="(userInfo.name+'-'+userInfo.permissionId) for userInfo in ngDialogData.allUserInfoList"
							"
                    >
                        <option value="">-- 请选择 --</option>
                    </select>
                </div>
            </div>
			<div class="form-group">
                <label class="control-label col-sm-2">修改的权限</label>
                <div class="col-sm-10">
                    <select class="form-control" name="mySelectPermissionList"
                            ng-model="item.permissionId"
                            ng-options="(userPermission.id+'-'+userPermission.name) for userPermission in ngDialogData.allUserPermissionList"
                    >
                        <option value="">-- 请选择 --</option>
                    </select>
                </div>
            </div>
            
        </form>
        <div class="modal-footer">
            <div class="ngdialog-buttons">
                <button type="button" class="ngdialog-button ngdialog-button-primary"
                        ng-click="postPermissionRequest(item)">{{ 'COMMIT' | translate }}
                </button>
                <button type="button" class="ngdialog-button ngdialog-button-secondary"
                        ng-click="closeThisDialog('Cancel')">{{ 'CLOSE' | translate }}
                </button>
            </div>
        </div>
    </div>

</script>

<script type="text/ng-template" id="deleteTopicDialog">
    <div>
        <div>
            <md-toolbar md-scroll-shrink="">
                <div class="md-toolbar-tools">
                    {{ngDialogData.topic}} {{ 'DELETE' | translate }}
                </div>
            </md-toolbar>
            <md-content>
                <md-card>

                </md-card>
                <div class="ngdialog-buttons">
                    <button type="button" class="ngdialog-button ngdialog-button-secondary"
                            ng-click="closeThisDialog('Cancel')">{{ 'CLOSE' | translate }}
                    </button>
                </div>
            </md-content>
        </div>
    </div>
</script>
